<template>
  <div>
    <div>
      <z-select/>
      <el-button color="#00665f" style="display: block;float: right" v-on:click="initData" @contextmenu.prevent="">查询
      </el-button>
    </div>
    <z-table
        :page-param="pageParam"
        :table-data="tableData"
        :table-columns="columns"
    >
    </z-table>
  </div>
</template>
<script>
import {gatewayLogPage} from '@/api/admin/gateway';

export default {
  name: 'gatewayLog',
  watch: {
    '$store.state.app.system': {
      handler() {
        this.initData();
      },
      deep: true,
      immediate: true,
    },
  },
  data() {
    return {
      tableData: [],
      pageParam: {
        current: 1,
        size: 20,
        total: 0,
      },
      columns: [
        {
          field: 'ip',
          title: 'ip',
          minWidth: 120,
        },
        {
          field: 'target_server',
          title: '目标服务',
          minWidth: 120,

        },
        {
          field: 'create_at',
          title: '创建时间',
        },
      ],
    }
  },
  mounted() {
    this.initData();
  },
  methods: {
    initData() {
      const systemCode = this.$store.state.app.system;
      if (systemCode) {
        const param = {...this.pageParam}
        gatewayLogPage(param).then(({code, data}) => {
          if (code === 200) {
            this.tableData = data;
          }
        }).catch(err => {
          console.log(err);
        });
      } else {
        this.$message.warning("请选择系统");
      }
    },
  },
}
</script>
